package com.swjd.service;

import com.swjd.po.User;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

//消费者
@Service
//selectorExpression SelectorType.SQL92 sql过滤
//MessageModel.BROADCASTING更改消费者模式为广播
@RocketMQMessageListener(topic = "topic10",
        consumerGroup = "group1",
        selectorExpression = "age>16",
        selectorType = SelectorType.SQL92,
        messageModel = MessageModel.BROADCASTING)
public class Consumer implements RocketMQListener<User> {

    //业务逻辑.

    @Override
    public void onMessage(User user) {
        System.out.println(user);
    }
}
